In recent years, digital broadcasting or network broadcasting using a moving picture encoding method such as MPEG (Moving Picture Experts Group), moving picture distribution using digital data, and the like have been actively performed. Such moving picture encoding methods enable moving picture data of a high resolution to be transferred by encoding moving pictures at a high compression ratio. Such moving picture compression techniques include motion compensation methods, one of which is a direct mode technique. The direct mode is an encoding mode for predicting and generating motion information on the basis of the motion information of encoded blocks. The number of bits that are necessary to encode motion information becomes unnecessary in the direct mode, leading to an increase in compression efficiency.
FIG. 1 is an explanatory view of the concept of a time direct mode as such a direct mode. In the time direct mode, a motion vector mvCo1 of an anchor block that is located in the same position as a target block in an anchor picture is scaled by using a time interval tb between a reference picture and a target picture, and a time interval td between the reference picture and the anchor picture. A motion vector mvL0 for L0 prediction as forward prediction and a motion vector mvL1 for L1 prediction as backward prediction are obtained with the following equations.mvL0=mvCo1×tb/td mvL1=−mvCo1×(td−tb)/td=mvL0−mvCo1
In a process for decoding moving picture data that is encoded in such a direct mode, a process for storing, in a memory, all pieces of information of motion vectors that can be possibly referenced in the direct mode is necessary when encoded picture data is decoded.
FIG. 2 illustrates an example of motion vector information that can possibly be referenced in a process executed in the direct mode as described above. In FIG. 2, the number of motion vectors for one macro block (MB) that is configured with, for example, 16×16 pixels is not fixed. Additionally, the size of an area from which motion vectors are obtained varies with a change in the number of motion vectors. Therefore, motion vectors for one macro block (MB) include many patterns of motion vectors.
FIG. 3 is an explanatory view of one example of a method for storing such motion vector information to be referenced in a memory. In FIG. 3, a fixed-size memory area is allocated to variable-length motion vector information the length of which varies due to variations in the patterns of macro blocks (MBs), and the variable-length motion vector information is stored in this memory area. If a fixed-size memory area is allocated in units of macro blocks, it is always necessary to transfer data of a fixed size when motion vector information is transferred, and the amount of processing for accessing the memory becomes extremely large.
FIGS. 4 and 5 are explanatory views of another method for storing, in a memory, variable-length data each having a different number of motion vectors and a different sized area from which motion vectors are detected, with respect to each of the macro blocks. In FIG. 4, for example, the number of motion vectors for a macro block 0 is two, and the number of motion vectors for a macro block 3 is seven.
FIG. 5 illustrates the method for storing motion vector information in which a variable-length area within the memory is allocated in accordance with the data length of motion vectors illustrated in FIG. 4. Information of motion vectors for each of the macro blocks illustrated in FIG. 4 is stored in variable-length areas in accordance with the number of motion vectors, or the like.
Processes for writing/reading motion vector information to be referenced to/from a memory in a conventional example of the method for storing motion vector information to be referenced in the memory in FIG. 5 are described with reference to FIGS. 6 to 9. FIG. 6 is a flowchart illustrating a motion vector information storing process executed in the conventional example of the method for storing motion vector information in the memory. This is a flowchart illustrating the details of the process for storing a motion vector to be referenced for one macro block (MB).
Once the process is started in FIG. 6, whether or not this process is a process executed for the first macro block of a macro block line is determined in step S101. Here, a fixed-size area within the memory is allocated to one macro block line (namely, a horizontal row of macro blocks). If this process is the process for the first macro block of the macro block line, it is necessary to store motion vector information to be referenced for the first macro block at the beginning of the fixed-size area allocated as described above. Accordingly, the flow goes to step S103 after the first address of that area is calculated in step S102. If this process is not the process for the first macro block of the macro block line, the flow immediately goes to step S103, in which a motion vector to be referenced for the corresponding macro block is calculated.
In step S104, whether or not an error has occurred in the calculation of the motion vector to be referenced is determined. If the error does not occur, the motion vector to be referenced is stored in step S105. Then, the process for storing a motion vector to be referenced is continued for the next macro block.
If it is determined in step S104 that an error has occurred, whether or not a macro block rewinding process is necessary is determined in step S106. If a motion vector to be referenced is miscalculated due to, for example, a loss of picture data or the like, the miscalculated motion vector exerts a lot of influence on the motion vector information of the macro block, which is calculated by using the miscalculated motion vector information, directly leading to deterioration in picture quality. Accordingly, it is desirable to execute a motion prediction process in the direct mode by replacing the motion vector information to be referenced with, for example, “0”, without using the motion vector information of the macro block in which the error has occurred. For example, the H.264 picture compression method using the direct mode does not stipulate the details of the process executed at the time of data decoding when error has occurred. However, the following description is provided by assuming that the motion prediction process in the direct mode is executed by replacing with “0” the motion vector information of a macro block where an error has occurred.
Additionally, if an error is detected from a macro block, there is a high possibility that picture quality will be deteriorated also in a macro block which is positioned preceding the macro block from which the error is detected and for which the process for storing a motion vector to be referenced has been completed. In this case, by executing an error concealment process after rewinding to the macro block positioned preceding the macro block from which the error is detected, the deterioration in the picture quality which is caused by the detected error can be prevented from occurring in the macro block positioned preceding the macro block where the error has occurred.
In step S106, whether or not such a macro block rewinding process is necessary is determined. If such a macro block rewinding process is not necessary, motion vector information resulting from the calculation performed for the macro block from which the error is detected is overwritten with “0” in step S107. In step S105, the motion vector to be referenced is stored.
If, for example, the macro block rewinding process is determined to be necessary empirically, and up to which macro block to be rewound is determined in step S106, the memory is again read at and after the first address of the motion vector information storage area for one macro block line, which is described with reference to FIG. 5 in step S108. The position of the macro block to be rewound, namely, the position of the macro block for which the error concealment process is to be executed is searched for in step S109. In step S107, the motion vector information resulting from the calculation is overwritten with “0” at and after the position of the rewound macro block. In step S105, the value of the motion vector to be referenced is overwritten with “0” in a range from the position of the rewound macro block to the position of the macro block from which the error is detected. Then, the process for storing a motion vector to be referenced is continued for the next macro block.
FIG. 7 is an explanatory view of results of writing motion vector information to be referenced by executing the process of FIG. 6. In FIG. 7, variable-length motion vector information of the macro block (MB) 0 and subsequent blocks are sequentially written to a fixed-size area that is described with reference to FIG. 5 and intended to store motion vector information for one macro block line. Here, assuming that an error is detected from the macro block 5, whether or not the macro block rewinding process is necessary is determined in step S106 upon detection of the error. If the process for rewinding up to the macro block 2 is determined to be necessary, data indicating that the motion vector information to be referenced is “0” is written as the data of the macro blocks 2 to 5. If an error is detected also from the macro block 6, the macro block rewinding process is determined to not be necessary in step S106. “0” is written also to the macro block 6 in steps S107 and S105. Then, subsequent processes are continued.
FIG. 8 is a flowchart illustrating the process for reading motion vector information in the conventional example of the method for storing motion vector information in FIG. 5. FIG. 8 is a flowchart illustrating the process for reading a motion vector to be referenced for one macro block, which corresponds to FIG. 6. Once the process is started, whether or not this process is a process for the first macro block of one macro block line is determined in step S111. If this process is the process for the first macro block, the first address of the one macro block line is set as an address of a RAM for storing motion vector information in step S112. Then, the flow goes to step S113 after the RAM is read. If this process is not the process for the first macro block, the flow immediately goes to step S113, in which the motion vector information to be referenced is read. In step S114, a direct vector is calculated. Then, the process for reading a motion vector to be referenced for the one macro block is terminated.
FIG. 9 is an explanatory view of the method for reading motion vector information to be referenced, the method being implemented with the process of FIG. 8. In FIG. 9, motion vector information to be referenced is read from the first macro block (namely, an MB (macro block) 0) and subsequent blocks of the macro block line. Here, “0”, which is stored as motion vector information in the memory, is read for the macro blocks 2 to 6.
The conventional example of the method for storing variable-length motion vector information of macro blocks in a memory and the processes for reading/writing the motion vector information stored with the conventional method have been described above in detail. However, an address at which motion vector information of a macro block to be rewound is stored cannot be uniquely obtained if an error is detected from a macro block and it is necessary to execute the error concealment process after rewinding to a macro block positioned preceding the macro block from which the error is detected. Accordingly, it is necessary to search for the information of the motion vector at the rewound position by again reading the content of the memory at and after the first address, and to replace the motion vector information with “0” at and after the rewound position. For such processes, an extremely large number of memory accesses and a long processing time are necessary.
Japanese Laid-open Patent Publication No. 2006-128920 “Error Concealment Method and Apparatus in Picture Signal Decoding System” discloses the technique for setting a motion vector in an area replacing an error area to “0” on the basis of a result of comparing a difference between a predicted motion vector in the error area and a motion vector in an adjacent area with a threshold value, or for adding a compensation value to the predicted motion vector in the error area in order to make a resultant vector function as the motion vector in the area replacing the error area.